<?php
$access_level = 3;
$page_title = 'eTAT';
require_once 'controller.php';

$groups = null;
if(isset($instructor) && isset($params->c)) {
	$course = $instructor->getCourse($params->c);
	$all_groups = $course->getAllGroups();
	if($all_groups) {
		foreach($all_groups as $ag) {
			$total = $ag->updateFeeds();
			$all_totals[$g->name] = $total;
		}
	}
	die(json_encode($all_totals));
} else if(isset($instructor) && isset($params->g)) {
	$g = $instructor->getGroup($params->g);
	$total = $g->updateFeeds();
	die(json_encode($total));
} else {
	$query = mysql_query("SELECT * FROM `group`") or die(mysql_error());
	while($r = mysql_fetch_object($query)) {
		$all_groups[] = new Group($r->id);
	}
	if($all_groups) {
		foreach($all_groups as $g) {
			$total = $g->updateFeeds();
			$all_totals[$g->name] = $total;
		}
	}
	die(print_r($all_totals));
}